import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import './plugins/element.js'
import 'element-ui/lib/theme-chalk/index.css';
import ZkTable from 'vue-table-with-tree-grid'
//注册富文本编辑器
import VueQuillEditor from 'vue-quill-editor'


// 设置全局样式
import './assets/css/global.css'
//设置富文本编辑器的样式
import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme

//设置axios的配置
import axios from 'axios'
//配置请求的路径
axios.defaults.baseURL = "https://www.liulongbin.top:8888/api/private/v1/"
Vue.prototype.$http = axios
//通过axios请求拦截器添加token，保证拥有获取数据的权限
//请求拦截
axios.interceptors.request.use(config => {
	//请求头对象，添加token验证的Authorization字段
	config.headers.Authorization = window.sessionStorage.getItem("token")
	return config
})

Vue.config.productionTip = false

//设置全局的树形结构(在cate.vue)
Vue.component("tree-table", ZkTable)
//将富文本编辑器设置为全局组件
Vue.use(VueQuillEditor, /* { default global options } */)

//设置时间过滤器
//padStart:如果某个字符串不够指定长度，会在头部或尾部补全。
Vue.filter('dataFormat',function(originVal){
	const dt = new Date(originVal)
	const y = dt.getFullYear()
	const m = (dt.getMonth() + 1 + '').padStart(2,'0')
	const d = (dt.getDate() + '').padStart(2,'0')
	
	const hh = (dt.getHours() + '').padStart(2,'0')
	const mm = (dt.getMinutes() + '').padStart(2,'0')
	const ss = (dt.getSeconds() + '').padStart(2,'0')
	
	return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
